<?php


class PictureController extends \Base\AbstractController {

    /**
     * @desc 列表页
     */
    public function listAction() {
        $request = $this->getRequest();
        $type    = (string)$request->get('type');

        if($type == 'home') {
            $where = ['type' => 1];
        } elseif($type == 'avatar') {
            $where = ['type' => 2];
        }

        $page = new \Lib\Paginator('picture');
        $page->where($where);
        $page->order('reorder DESC');
        $this->assign('count', $page->count());
        $this->assign('page', $page->getPage());
        $this->assign('perPage', $page->getPerpage());
        $this->assign('lists', $page->lists());

    }

    public function addAction() {
        $request = $this->getRequest();
        $id      = $request->get('id');

        $pictureMapper = \Mapper\PictureModel::getInstance();
        $pictureModel  = new PictureModel();
        $data          = $pictureMapper->findById($id);

        if($request->isPost()) {
            var_dump($request);exit;


        }

        $this->display('edit');
        return false;

    }
}
